#!/bin/sh
# vim: set ts=4:
#
# Runs unit tests and linter.
#
set -e

#======================  Functions  ======================#

report_coverage() {
	echo ''
	cat "$TEMP_DIR/luacov.report.out" | sed -nE '/^Summary/,$p' | tail -n+4
}


#========================  Main  =========================#

# Go to the project's root directory.
cd "$(dirname "$0")/.."

. script/common.sh
setup_path
script/bootstrap

einfo '==> Running unit tests...'
busted --shuffle --verbose --coverage
report_coverage

einfo '==> Running linter...'
luacheck lib/*
